﻿ 
<!DOCTYPE html>  
<html>  
<head>  
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
    <meta name="keywords" content="职位Offer">  
    <meta name="description" content="职位Offer">  
    <title>职位Offer管理</title>  
    
    <%@ include file="/WEB-INF/inc/default.jsp"%>
    <jsp:include page="/WEB-INF/inc/dic.jsp"/>    

</head>  
<body>  
    
 
    
    <div class="easyui-layout" align=center style="width:100%;height:600px;overflow:hidden"> 
    	   <div data-options="region:'north',split:true" style="width:100%;height:300px">  
              <table id="dg"  class="easyui-datagrid" style="height:290px"  
                  url="/project/contractJobCvOffer/cvofferlist.do"  
                  toolbar="#toolbar" pagination="true"  
                  rownumbers="true" fitColumns="true" loadMsg="正在查询,请稍候..." singleSelect="false">  

              </table>  
         </div>
         <div data-options="region:'center',iconCls:'icon-ok'" style="width:100%"> 
              	<div id="tab_panel" class="easyui-tabs" style="height:250px">  
                         
                         <div title="背景调查" url="/project/contractJobCvBackground/managerPage.do" >  
                             <iframe " name="tab_panel5" src="" style="width:98%;height:99%"></iframe>
                         </div>
                         <div title="成功候选人跟进" url="/project/contractJobCvCrm/managerPage.do" >  
                             <iframe " name="tab_panel6" src="" style="width:98%;height:99%"></iframe>
                         </div>
                         <div title="业绩分配" url="/project/contractJobOfferPartner/managerPage.do" >  
                             <iframe " name="tab_panel6" src="" style="width:98%;height:99%"></iframe>
                         </div>
                         
                </div> 
          </div>
    </div>
    
    
    <div id="toolbar">  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="addPn()">新增账单</a>          
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="find()">查询</a>
    </div>  
    <!-- edit form窗体（开始） -->  
    <div id="dlg_pn"  style="display:none;">  
    	 <!--
        <form id="fm" method="post" novalidate>  
                   
        
        	  	  	 <input type="hidden" name="id" > 
        	  	  	 <input type="hidden" name="offerId" >
        	  	  	 <input type="hidden" value="0" name="status" >
	        		     <div class="fitem">  
                     <label style="width:100px">客户:</label>                       
                     <input name="custName" disabled="true" class="easyui-box">                       
                   </div>	        		     
	        		     <div class="fitem">  
                     <label style="width:100px">职位名:</label>                       
                     <input name="jobName" disabled="true" class="easyui-box">                       
                   </div>	        		           		     
                   <div class="fitem">  
                     <label style="width:100px">Offer人选:</label>                       
                     <input name="cvName" disabled="true" class="easyui-box">                       
                   </div>
	        		     <div class="fitem">  
                     <label style="width:100px">账单编号<font color="red">*</font>:</label>                                            
                     <input name="nbr" class="easyui-box easyui-validatebox"  required="true">                       
                   </div> 
	        		     <div class="fitem">  
                     <label style="width:100px">offer收款金额<font color="red">*</font>:</label>                       
                     <input name="finalAr" class="easyui-numberbox easyui-validatebox" >                       
                   </div>	        		     
        	  	   	 <div class="fitem">  
                     <label style="width:100px">货币单位<font color="red">*</font>:</label>  
                     <input class="easyui-combobox easyui-validatebox"   name="currency" style="width:200px;"  data-options="data:__getConstantCategory('MoneyType'),valueField:'code', textField:'value', multiple:false,panelHeight:'auto',mode:'remote' ">
                   </div>  	        	  	   	
	        		     <div class="fitem">  
                     <label style="width:100px">收款分公司:</label>                                                                 
                     <input class="easyui-combobox"   name="branchNbr" style="width:200px;"  data-options="url:'/auth/systemBranchCompany/listbranchcompany.do',valueField:'branchNbr', textField:'name', multiple:false,panelHeight:'auto',mode:'remote' ">                      
                   </div> 
	        		    
	        		     <div class="fitem">  
                     <label style="width:100px">备注:</label>                                                                 
                     <textarea name="comment" style="height:100px;width:200px"></textarea>                 
                   </div> 
	        		    
        </form>  
         <div  style="text-align:center">  
          <a href="javascript:void(0)" id="btn-save" class="easyui-linkbutton" iconCls="icon-ok" ">Save</a>  
          <a href="javascript:void(0)" id="btn-close" class="easyui-linkbutton" iconCls="icon-cancel">关闭</a>  
        </div>
        -->
    </div>    
    <!-- edit form窗体（结束） -->  
    <!-- query form窗体(开始) -->  
    <div id="dlg_query" style="display:none;">  
        <!--
        <form id="fm_query" method="post" novalidate>  
                          
	        		     <div class="fitem">  
                     <label style="width:100px">客户名:</label>                       
                     <input name="custName" class="easyui-box">                       
                   </div>	        		     
	        		     <div class="fitem">  
                     <label style="width:100px">招聘职位:</label>                       
                     <input name="jobName" class="easyui-box">                         	
                   </div>  	        	
                   <div class="fitem">  
                     <label style="width:100px">人选姓名:</label>                       
                     <input name="cvName" class="easyui-box">                         	
                   </div>  	        	
                   <div class="fitem">  
                     <label style="width:100px">职位负责人:</label>                                                                                      
                     <input class="easyui-combobox" name="jobManager" style="width:200px;"  data-options="url:'/auth/systemUser/userlist.do',valueField:'account', textField:'name', multiple:false,panelHeight:'auto',mode:'remote' ">
                     
                   </div> 
                   
                   
	        		    
              
              
        </form>  
        <div  style="text-align:center">  
          <a href="javascript:void(0)" id="btn-query" class="easyui-linkbutton" iconCls="icon-ok" ">查询</a>  
          <a href="javascript:void(0)" id="btn-query-close" class="easyui-linkbutton" iconCls="icon-cancel">关闭</a>  
        </div>
        -->
    </div> 
    <!-- query form窗体(结束) -->  
    
    <script type="text/javascript">  
        var url;  
        var jobId='0';
       	var offerId='0';
       	var recomId='0';
       	var cvName='';
       	
       	var optWin = $.window({
		       		 title:"新增账单",
		       		 tplRef:"dlg_pn",//这个属性指定模板id
		       		 height:500,		       		 
		       		 width:400,
		       		 closed:true,		       		 
		       		 onComplete:function(){
		       		 	  //窗口里面的初始化,最好是在这个事件里面进行
		       		 	  var curWin=this;
		       		 	  var doForm=curWin.find('#fm');
		       		 	  curWin.doForm=doForm;
		       		 	  this.find("#btn-close").click(function(){		       		 	  	
		       		 	  	   curWin.window('close');
		       		 	  });
		       		 	  this.find("#btn-save").click(function(){		       		 	  	
		                 		  if (!doForm.form('validate')) return;
		                 		  
		                 		  doForm.form('submit',{  
                            url: curWin.url,  
                            onSubmit: function(){                              	  
                                return doForm.form('validate');  
                            },  
                            success: function(result){  
                                var result = eval('('+result+')');                      
                                if (result.success == true){  
                                    //$.messager.alert('信息',result.msg,'info');  
                                    alert(result.msg);
                                    curWin.window('close');
                                    //curWin.openWin.reload();
                                    
                                } else {  
                                    //$.messager.alert('错误',result.msg,'error');
                                    alert(result.msg);
                                }  
                            }  
                       }); 		 
		              });
		       		   
		       		 }
		    });
		    
		    var queryWin = $.window({
		       		 title:"录入人选查询",
		       		 tplRef:"dlg_query",//这个属性指定模板id
		       		 height:200,		       		 
		       		 closed:true,		       		 
		       		 onComplete:function(){
		       		 	  //窗口里面的初始化,最好是在这个事件里面进行
		       		 	  var curWin=this;
		       		 	  var doForm=curWin.find('#fm_query');
		       		 	  curWin.doForm=doForm;
		       		 	  this.find("#btn-query-close").click(function(){		       		 	  	
		       		 	  	   curWin.window('close');
		       		 	  });
		       		 	  this.find("#btn-query").click(function(){
		       		 	  			                 		  
		                 		 //var formdata=$('#fm_query').formToArray(); 
		                 		 curWin.window('close');
		                 		 var formdata=curWin.find('#fm_query').formToArray();   		 
		                 		 curWin.openWin.query(formdata);
		              });
		       		   
		       		 }
		    });
       	
        function addPn(){         	 
            var rows = $('#dg').datagrid('getSelections');
            if (!rows||rows.length==0){
            	 $.messager.alert('提示','请选择要修改的行','info');
            	 return;
            }
            if (!rows||rows.length>1){
            	 $.messager.alert('提示','不能选择多行','info');
            	 return;
            }
            if (rows){ 
            	optWin.window('open'); 
              optWin.openWin=window;    
              optWin.url='/project/accountPn/save.do';  
              optWin.doForm.form('clear');
              optWin.window('setTitle','新增账单');
              optWin.doForm.find('input[name="offerId"]').attr("value",rows[0].offerId);  
              optWin.doForm.find('input[name="status"]').attr("value",'0');
              optWin.doForm.find('input[name="custName"]').attr("value",rows[0].custName);  
              optWin.doForm.find('input[name="cvName"]').attr("value",rows[0].cvName);  
              optWin.doForm.find('input[name="jobName"]').attr("value",rows[0].jobName);  
            }	
            
            
        }  
        function edit(){  
            //var row = $('#dg').datagrid('getSelected');  
            var rows = $('#dg').datagrid('getSelections');
            if (!rows||rows.length==0){
            	 $.messager.alert('提示','请选择要修改的行','info');
            	 return;
            }
            if (!rows||rows.length>1){
            	 $.messager.alert('提示','不能选择多行','info');
            	 return;
            }
            if (rows){  
                $('#dlg').dialog('open').dialog('setTitle','修改职位Offer');  
                //$('#fm').form('load',rows[0]);  
                $('#fm').form('load','/project/contractJobCvOffer/get.do?id='+rows[0].id);  
                url = '/project/contractJobCvOffer/update.do';
            }  
        }  
        function save(){          	   
        	  if (!$('#fm').form('validate')) return; 
            $('#fm').form('submit',{  
                url: url,  
                onSubmit: function(){  
                    return $(this).form('validate');  
                },  
                success: function(result){  
                    var result = eval('('+result+')');  
                    console.log(result);
                    if (result.success == true){  
                        $.messager.alert('信息',result.msg,'info');  
                        $('#dlg').dialog('close');      // close the dialog  
                        $('#dg').datagrid('reload');    // reload the user data  
                    } else {  
                        $.messager.alert('错误',result.msg,'error');
                    }  
                }  
            });  
        }  
        function deletes(){  
            var row = $('#dg').datagrid('getSelected');  
            
            var rows = $('#dg').datagrid('getSelections');  

            if (!rows||rows.length==0){
            	 $.messager.alert('提示','请选择要删除的行','info');
            	 return;
            }
            if (rows){  
                $.messager.confirm('重要提示','确定要删除?',function(r){  
                    if (r){  
                        $.post('/project/contractJobCvOffer/delete.do',{ids:getRecordArray(rows,'id').join(',')},function(result){  
                            if (result.success){  
                                $('#dg').datagrid('reload');    // reload the user data  
                            } else {  
                                 
                                $.messager.alert('错误',result.errorMsg,'error'); 
                            }  
                        },'json');  
                    }  
                });  
            }  
        }  
         function find(){  
              
         
                 queryWin.window('open');   
                 queryWin.openWin=window; 
              
        } 
        	
        function query(formdata){  
                
                $('#dg').datagrid({
	                  queryParams: array2json(formdata)
                });
              
        }    
        
        
        //生成grid的字段,需要字典的自动转换
        $('#dg').datagrid({
        	   columns:[[
        	   	
        	   	   {field:'custName',title:'客户简称', width:100}
        	   	   ,{field:'jobName',title:'职位名', width:100}
        	   	   ,{field:'cvName',title:'候选人名', width:100}
        	   	   ,{field:'mobile',title:'手机', width:100,hidden:true}
        	   	   ,{field:'email',title:'电邮', width:100,hidden:true}
        	   	   ,{field:'applyD',title:'录用日期', width:100,
        	   	   	formatter: function(value,row,index){
        	   		      	
        	   		      	if (value && value.length >= 10)
														return value.substring(0, 10)
        	   		      }
        	   	   	}
        	   	   ,{field:'ondutyD',title:'预估上班日期', width:100,
        	   	   	formatter: function(value,row,index){
        	   		      	
        	   		      	if (value && value.length >= 10)
														return value.substring(0, 10)
        	   		      }
        	   	   	}
        	   	   
        	   	   ,{field:'checkinD',title:'实际上班日期', width:100,
        	   	   	formatter: function(value,row,index){
        	   		      	
        	   		      	if (value && value.length >= 10)
														return value.substring(0, 10)
        	   		      }
        	   	   	}
        	   	   
        	   	   ,{field:'expiredD',title:'试用期到期日', width:100}
        	   	   
        	   	   ,{field:'status',title:'录用结果', width:100,
        	   		      formatter: function(value,row,index){
        	   		      	return __getConstantCategoryCodeValue('OfferStatus', value);
        	   		      },hidden : true
        	   	     }
        	   	   
        	   	   ,{field:'isPn',title:'账单', width:100}
        	   	   ,{field:'estimateAr',title:'预计收费', width:100}
        	   	   ,{field:'finalAr',title:'实际收费', width:100}
        	   	   ,{field:'jobManager',title:'职位负责人', width:100}
        	   	   ,{field:'jobContacter',title:'客户联系人', width:100,hidden:true}
        	   	   ,{field:'jobContacterPhone',title:'联系人电话', width:100,hidden:true}        	   	   
        	   	   ,{field:'jobContacterEmail',title:'联系人电邮', width:100,hidden:true}
        	   	           	   	           	   	   
        	   	
        	   	
        	   ]]
        	   ,onDblClickRow: function(rowIndex, rowData){
        	    	//$('#dlg').dialog('open').dialog('setTitle','修改职位Offer');                  
               // $('#fm').form('load','/project/contractJobCvOffer/get.do?id='+rowData.id);  
                //url = '/project/contractJobCvOffer/update.do';        	    	
        	    }
        	    ,onClickRow: function(rowIndex, rowData){
        	    	
        	    	var tab = $('#tab_panel').tabs('getSelected');
        	      jobId=rowData.jobId;    
        	      recomId=rowData.recomId;    
        	      cvName=rowData.cvName;    
        	      offerId=rowData.offerId;
        	    	tab.find('iframe')[0].contentWindow.location.href=tab.attr('url')+"?jobId="+jobId+"&recomId="+recomId+"&offerId="+offerId+"&cvName="+cvName;
                	    	
        	    }
        }); 
        //完成-生成grid的字段
        function reloadtab(tab,row){
        	
        	  if (tab.attr('url')='/project/contractJobCvBackground/managerPage.do')
        	    	   tab.find('iframe')[0].contentWindow.location.href=tab.attr('url')+"?recomId="+recomId+"&offerId="+offerId;
        	    	else if (tab.attr('url')='/project/contractJobCvCrm/managerPage.do')
        	    		 tab.find('iframe')[0].contentWindow.location.href=tab.attr('url')+"?recomId="+recomId;
        	    	else 	if (tab.attr('url')='/project/contractJobOfferPartner/managerPage.do')
        	    		 tab.find('iframe')[0].contentWindow.location.href=tab.attr('url')+"?offerId="+offerId;
        }
        $('#dg').datagrid({
	            onLoadSuccess: function(data){		
              if(data.total&&data.total>0) {
              	  $('#dg').datagrid('selectRow',0);
              	  var rowData=$('#dg').datagrid('getSelected');
              	          	        
        	        jobId=rowData.jobId;    
        	        recomId=rowData.recomId;    
        	        cvName=rowData.cvName;  
        	        offerId=rowData.offerId;
        	        
        	        var tab=$('#tab_panel').tabs('getTab', 0);
        	        tab.find('iframe')[0].contentWindow.location.href=tab.attr('url')+"?jobId="+jobId+"&recomId="+recomId+"&offerId="+offerId+"&cvName="+cvName;
              }	
	          }
	       });
        $('#tab_panel').tabs({
        	    onSelect: function(title,index){
        	    
        	    	var tab=$('#tab_panel').tabs('getTab', index);
        	    
        	      
        	    	tab.find('iframe')[0].contentWindow.location.href=tab.attr('url')+"?jobId="+jobId+"&recomId="+recomId+"&offerId="+offerId+"&cvName="+cvName;
        	    	
        	    }
        });
        
    </script>  
     
     

     
     
     
</body>  
</html>